from solar_system import SolarSystem

import numpy as np

NUMERIC_TYPE = np.float64

class Simulation(object):
    def __init__(self, steps=None):
        self.integrator = None
        self.outputs = None
        self.inputs = None
        self.steps = steps

        self.system = SolarSystem()

    def initialize(self):
        for input in self.inputs:
            input.initialize()
            input.read(self.system)
            input.finalize()
        for output in self.outputs:
            output.initialize()

    def finalize(self):
        for output in self.outputs:
            output.finalize()
    
    def run(self):
        self.initialize()
        for step in xrange(1, self.steps + 1):
            self.system = self.integrator.integrate(self.system, step)
            for output in self.outputs:
                output.output(self.system, step)
        self.finalize()
